<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--#include file="DataLoad.asp"-->
<html>
<head>
<title><%=GuildName%> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="DKP WOW GUILD">
<meta name="Description" content="">
<link href="<%=StylePath%>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<%=StylePath%>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
</head>

<body>
<div class="main">
<%
if request("action")="add" then
call eventadd()
elseif request("action")="edit" then
call eventedit()
elseif request("action")="del" then
call eventdel(request("id"))
end if
Sub eventadd()
	'验证提交数据有效性
	Dim errorinfo
	if not IsNumeric(request("postid")) then errorinfo=errorinfo & "<li>内部参数错误</li>"
	if not IsDate(request("event_date")&" "&request("event_time")) then errorinfo=errorinfo & "<li>时间格式不正确,请参考旁边的格式</li>"
	if request("event_class")="加入" or  request("event_class")="离开" or  request("event_class")="拾取" then
		if request("object")="" then errorinfo=errorinfo & "<li>请选择事件人员</li>"
	elseif request("event_class")="分解" then
		if request("object2")="" then errorinfo=errorinfo & "<li>请注明事件的物品名称</li>"
	elseif request("event_class")="发现" or request("event_class")="首次" or request("event_class")="击杀" then
		if request("object2")="" then errorinfo=errorinfo & "<li>请注明事件的对象名称</li>"
	else
		if request("object2")="" then errorinfo=errorinfo & "<li>请填写事件的解释信息</li>"
		if not IsNumeric(request("event_dkp")) then errorinfo=errorinfo & "<li>请填写事件所得DKP</li>"
	end if
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<div class='message'><h3>表单信息有误,提示如下:</h3><div><ul>"&errorinfo&"</ul>"
		Response.write "<a href='"&Url&"' class='abtn'>返回修改</a></div></div>"
	else
		'写入数据库
		Sql="Select * from raid_event where (id is null)"
		rs.open sql,conn,1,3
		rs.addnew
		rs("event_raidid")=request("postid")
		rs("event_time")=Cdate(request("event_date") & " " & request("event_time"))
		rs("event_class")=request("event_class")
			if request("event_class")="分解" or request("event_class")="仓库" or request("event_class")="发现" or request("event_class")="首次" or request("event_class")="击杀" or request("event_class")="团队事件" or request("event_class")="活动事件" then
				rs("event_object")="-"
			else
				rs("event_object")=trim(request("object"))
			end if
			if Instr(request("object"),"|") and Left(request("object"),1)<>"|" then
				rs("event_object")="|"&rs("event_object")
			end if
			if Instr(request("object"),"|") and Right(request("object"),1)<>"|" then
				rs("event_object")=rs("event_object")&"|"
			end if
		rs("event_object2")=trim(request("object2"))
		rs("raid_class")=request("class_name")
		if request("event_class")="加入" or  request("event_class")="离开" or  request("event_class")="发现" or  request("event_class")="首次" or request("event_dkp")="" then
			rs("event_dkp")=0
		else
			rs("event_dkp")=request("event_dkp")
			rs("event_dkp2")=request("event_dkp2")
		end if
		rs.update
		rs.close
		Response.redirect Url
	end if
end sub


sub eventdel(id)
	if not IsNumeric(request("postid")) then exit sub
	sql="delete 1 from raid_event where id="&request("id")
	conn.execute(sql)
	Response.redirect Url
end sub


Sub eventedit()
	'验证提交数据有效性
	Dim errorinfo
	if not IsNumeric(request("postid")) then errorinfo=errorinfo & "<li>内部参数错误</li>"
	if not IsDate(request("event_date")&" "&request("event_time")) then errorinfo=errorinfo & "<li>时间格式不正确,请参考旁边的格式</li>"
	if request("event_class")="加入" or  request("event_class")="离开" or  request("event_class")="拾取" then
		if request("object")="" then errorinfo=errorinfo & "<li>请选择事件人员</li>"
	elseif request("event_class")="分解" then
		if request("object2")="" then errorinfo=errorinfo & "<li>请注明事件的物品名称</li>"
	elseif request("event_class")="发现" or request("event_class")="首次" or request("event_class")="击杀" then
		if request("object2")="" then errorinfo=errorinfo & "<li>请注明事件的对象名称</li>"
	else
		if request("object2")="" then errorinfo=errorinfo & "<li>请填写事件的解释信息</li>"
		if not IsNumeric(request("event_dkp")) then errorinfo=errorinfo & "<li>请填写事件所得DKP</li>"
	end if
	'验证///

	if errorinfo<>"" then
		'抛出错误提示
		Response.write "<div class='message'><h3>表单信息有误,提示如下:</h3><div><ul>"&errorinfo&"</ul>"
		Response.write "<a href='"&Url&"' class='abtn'>返回修改</a></div></div>"
	else
		'写入数据库
		Sql="Select * from raid_event where id="&request("postid")
		rs.open sql,conn,1,3
		rs("event_raidid")=request("rid")
		rs("event_time")=Cdate(request("event_date") & " " & request("event_time"))
		rs("event_class")=request("event_class")
			if request("event_class")="分解" or request("event_class")="仓库" or request("event_class")="发现" or request("event_class")="首次" or request("event_class")="击杀" or request("event_class")="团队事件" or request("event_class")="活动事件" then
				rs("event_object")="-"
			else
				rs("event_object")=trim(request("object"))
			end if

			if Instr(request("object"),"|") and Left(request("object"),1)<>"|" then
				rs("event_object")="|"&rs("event_object")
			end if
			if Instr(request("object"),"|") and Right(request("object"),1)<>"|" then
				rs("event_object")=rs("event_object")&"|"
			end if
		rs("event_object2")=trim(request("object2"))
		rs("raid_class")=request("class_name")
		if request("event_class")="加入" or  request("event_class")="离开" or  request("event_class")="发现" or  request("event_class")="首次" then
			rs("event_dkp")=0
		else
			rs("event_dkp")=request("event_dkp")
		end if
			rs("event_dkp2")=request("event_dkp2")
		rs.update
		rs.close
		Response.redirect "admin_report.asp?action=collect2&id="&request("rid")
	end if
end sub
%>
</div>
</body>
</html>